<!DOCTYPE HTML>
<html lang="zh-cn" ng-app="timeExample">
	<head>
		<meta charset="UTF-8">
		<title>injector</title>
		<style type="text/css">
			.ng-cloak {
				display: none;
			}
		</style>
	</head>
	<body>
		<div ng-controller="ClockCtrl" class="ng-cloak">
			Current time is : {{time.now}}
		</div>
		<script src="libs/angular.min.js" type="text/javascript"></script>
		<script type="text/javascript">
			angular.module("timeExample", []).factory("myClock", function($timeout) {
				var time = {};
				(function tick() {
					time.now = new Date().toString();
					$timeout(tick, 1000);
				})();
				return time;
			});
			/**
			 *
			 * @param $scope
			 * @param myClock 这里自动插入了依赖的myClock！！
			 * @constructor
			 */
			function ClockCtrl($scope, myClock) {
				$scope.time = myClock;
			}
		</script>
	</body>
</html>